//
//  DebugNotificationManager.m
//  YK_DebugManager
//
//  Created by edward on 2021/11/27.
//

#import "DebugNotificationManager.h"

@interface DebugNotificationManager ()
///
@property (nonatomic, strong, readwrite) NSMutableArray *lists;

@end

@implementation DebugNotificationManager


static DebugNotificationManager *_instance;

+ (id)allocWithZone:(struct _NSZone *)zone
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [super allocWithZone:zone];
    });

    return _instance;
}

+ (instancetype)sharedInstance
{
    if (_instance == nil) {
        _instance = [[DebugNotificationManager alloc] init];
        _instance.isRecordNotification = YES;
    }
    return _instance;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}

- (void)addListType:(NSInteger)type name:(nullable NSNotificationName)name object:(nullable id)object userInfo:(nullable NSDictionary *)userInfo
{
    if (type == 2 || type == 3 || type == 4) {//暂时只监听post
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setValuesForKeysWithDictionary:userInfo];
        [dic setValue:@(type).stringValue forKey:@"type"];
        [dic setValue:name forKey:@"name"];
        [dic setValue:object?:@"" forKey:@"object"];
        
//        if (self.reloadData) {
//            self.reloadData();
//        }
        
        NSBundle *bundle = [NSBundle bundleForClass:[object class]];
         if (bundle == [NSBundle mainBundle]) {
             [self.lists insertObject:dic atIndex:0];
         } else {
             //系统类
         }
    }
}

- (NSMutableArray *)lists
{
    if (!_lists) {
        _lists = [NSMutableArray array];
    }
    return _lists;
}

@end
